{% extends "base.html" %}
    {% block head %}
        <title>活动管理-编辑活动</title>
        <script>
        {% if error %}
        alert("{{error}}");
        {% end %}
        $(function(){
            $("#remove").click(function(){
                var who = $("#applied").val().slice(0,12);
                if (who!="")
                {
                    if (confirm("确认删除？"))
                    {   $.get("/admin/{{act.get("uuid")}}/delete/" + who, {},
                        function(data){
                            if (data=="OK")
                            {
                                alert("删除成功！");
                                location.reload();
                            }
                            else
                            {
                                alert("删除失败！");
                            }
                        });
                    }
                }
                return False;
            });
        })
        </script>
    {% end %}
    {% block body %}
        <h2>编辑活动</h2>
        <form action="" method="post" accept-charset="utf-8"> 
            <p><span>活动名称</span></p>
            <p><input type="text" id="caption" name="caption" size="30" value="{{act.get("caption", "")}}"/></p>
            <p><span>活动内容</span></p>
            <p><textarea rows="15" id="content" name="content" cols="60" >{{act.get("content", "")}}</textarea></p>
            <p><span>名额</span></p>
            <p><input type="text" id="amount" name="amount" size="30" value="{{act.get("amount", "")}}"/></p>
            <p><span>截止时间</span></p>
            {% import datetime %}
            <p><input type="text" id="endtime" name="endtime" size="30" value="{{act.get("endtime", "") or (datetime.datetime.utcnow() + datetime.timedelta(hours=8)).strftime("%Y-%m-%d %H:00:00")}}"/></p>
            <p>
                <span>已报名</span>
                <select name="applied" id="applied" value="">
                    {% for applier in act.get("appliers", {}) %}
                    <option>{{applier.encode("utf-8")+"|"+users.get(applier, u"错误用户")}}</option>
                    {% end %}
                </select>
                <a href="javascript:void(0)" onclick="" id="remove">删除</a>
            </p>            
            <p><button type="submit" name="提交">提交</button><input type="button" name="return" value="返回" onclick="location.href='/'"/></p>             
        </form>
    {% end %}
